//    Copyright (C) 2013  <lugocreation@gmail.com>
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
package org.jpgolay.me.stock.inventory;

import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.*;
import org.jpgolay.gui.fixed.SearchBox;
import org.jpgolay.gui.fixed.TableViewer;

public class InventoryListPanel extends JPanel {

    public InventoryListPanel() {
        jPanel = null;
        searchBox = null;
        tableViewer = null;
        jPanel1 = null;
        printLabelButton = null;
        initialize();
    }

    private void initialize() {
        setLayout(new BorderLayout());
        add(getJPanel(), "Center");
    }

    private JPanel getJPanel() {
        if (jPanel == null) {
            jPanel = new JPanel();
            jPanel.setLayout(new BorderLayout());
            jPanel.add(getTableViewer(), "Center");
            jPanel.add(getJPanel1(), "North");
        }
        return jPanel;
    }

    private SearchBox getSearchBox() {
        if (searchBox == null) {
            searchBox = new SearchBox();
            searchBox.setPreferredSize(new Dimension(330, 27));
        }
        return searchBox;
    }

    private TableViewer getTableViewer() {
        if (tableViewer == null) {
            tableViewer = new TableViewer();
        }
        return tableViewer;
    }

    private JPanel getJPanel1() {
        if (jPanel1 == null) {
            jPanel1 = new JPanel();
            jPanel1.add(getSearchBox(), null);
            jPanel1.add(getPrintLabelButton(), null);
        }
        return jPanel1;
    }

    private JButton getPrintLabelButton() {
        if (printLabelButton == null) {
            printLabelButton = new JButton();
            printLabelButton.setPreferredSize(new Dimension(22, 22));
            printLabelButton.setFocusPainted(false);
            printLabelButton.setBorderPainted(false);
            printLabelButton.setContentAreaFilled(false);
            printLabelButton.setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/gui/iconBar/images/printer.png")));
            printLabelButton.setToolTipText("Imprimer la liste");
        }
        return printLabelButton;
    }

    public SearchBox getSearch() {
        return getSearchBox();
    }

    public TableViewer getTable() {
        return getTableViewer();
    }

    public JButton getPrintLabel() {
        return getPrintLabelButton();
    }
    private JPanel jPanel;
    private SearchBox searchBox;
    private TableViewer tableViewer;
    private JPanel jPanel1;
    private JButton printLabelButton;
}
